﻿<div ms-controller="SZMXLIST">
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">收支明细：</h5>
            <ul class="tab-type ft14">
                <li><span class="active" ms-click="ChangeType('')">全部</span></li>
                <li ms-click="ChangeType(1)"><span>收入</span></li>
                <li ms-click="ChangeType(2)"><span>支出</span></li>
            </ul>
        </div>

        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" placeholder="搜索备注信息" ms-duplex="search.searchcontent">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->
    <div class="default-tab ft14 pt20">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc" style="width:50px;">
                        
                    </th>
                    <th ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{im.ColText}}</th>                    
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="ListData">
                    <td class="tc">
                        
                    </td>
                    <td ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{FnFormat(el[im.ColName],im)|html}}</td>
                    <!--<td>

                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="编辑" ms-click="AddView('RWGL','修改任务',el.ID,$event)">
                            <i class="iconfont icon-bianji"></i>
                        </a>
                        <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除" ms-click="Del(el,$event)">
                            <i class="iconfont icon-shanchu"></i>
                        </a>
                    </td>-->
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>

        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="ListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>
</div>

<script>

    var tempindex = avalon.define({
        $id: "SZMXLIST",
        listType: "",
        curRWType: "",
        ChangeType: function (type) {
            tempindex.listType = type;
            tempindex.GetLIST();
        },
        SelectType: function (type) {
            model.search.seartype = type;
            tempindex.GetLIST();
        },
        SelectRWType: function (type) {
            tempindex.curRWType = type;
            tempindex.GetLIST();
        },
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        InitWigetData: function () {
            model.search.seartype = "0";
            //显示的列名
            model.ShowColumns.clear();
            model.ShowColumns.pushArray([
                     { "ColName": "SerialID", "ColText": "流水号", "IsSel": true, "format": "text" },
                     { "ColName": "CRDate", "ColText": "时间", "IsSel": true, "format": "dateformat"},
                     { "ColName": "Memo", "ColText": "备注", "IsSel": true, "format": "text", "len": "999" },
                     { "ColName": "Change", "ColText": "收入", "IsSel": true, "format": "sr" },
                     { "ColName": "Change", "ColText": "支出", "IsSel": true, "format": "zc" },
                     { "ColName": "Balance", "ColText": "余额", "IsSel": true, "format": "sr" }
            ]);
            //类型数据
            tempindex.GetLIST();
        },

        GetLIST: function () {
            model.page.pageindex = 1;
            model.ListData.clear();
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETSZMX', { P1: model.search.searchcontent, pagecount: model.page.pagecount, p: 1, P2: tempindex.listType }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ListData = resultData.Result;
                    if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    model.page.total = resultData.Result1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETSZMX', { p: e.curr, P1: model.search.searchcontent, pagecount: model.page.pagecount, P2: tempindex.listType }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        model.ListData = resultData.Result;
                                        if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }

            })
        },
        Del: function (ForCode, el, event) {
            if (event) {
                event.stopPropagation();
            }
            ComFunJS.winconfirm("确认要删除吗？", function () {
                $.getJSON("/API/VIEWAPI.ashx?Action=RWGL_DELRWGLMODEL", { P1: el.ID }, function (r) {
                    if (r.ErrorMsg == "") {
                        model.ListData.remove(el);
                        ComFunJS.winsuccess("操作成功");
                    }
                })
            }, function () { })

        }
    })
    //@ sourceURL=RWGLTEMP.js;
</script>
